#!/usr/bin/env python
# coding: utf-8

# In[1]:


import numpy as np
import pandas as pd 
import matplotlib.pyplot as plt


# In[5]:


girl = pd.read_excel('./体测分数_女生.xls')
boy = pd.read_excel('./体测分数_男生.xls')


# In[6]:


boy.describe().round(1)


# In[7]:


grades = pd.cut(boy['男1000米跑'],bins = 3)
data_b = grades.value_counts()
data_b


# In[35]:


#男1000米跑饼图
plt.figure(figsize=(5,5))
plt.rcParams['font.size']=16
_ = plt.pie(x=data_b,
            labels = data_b.index,
            autopct = '%0.2f%%')
plt.rcParams['font.sans-serif'] = 'songti sc' 
plt.title('   男1000米跑分布饼图   ',fontsize = 28,backgroundcolor = '#c5b783',color = 'white' ,pad = 30)


# In[14]:


grade_y = pd.cut(boy['男引体'],bins = 3)
data_by = grade_y.value_counts()
data_by


# In[36]:


#男引体饼图
plt.figure(figsize=(5,5))
_ = plt.pie(x=data_by,
       labels = data_by.index,
       autopct = '%0.2f%%')
plt.rcParams['font.sans-serif'] = 'songti sc' 
plt.title('   男引体分布饼图   ',fontsize = 28,backgroundcolor = '#c5b783',color = 'white' ,pad = 30)


# In[18]:


#女800米跑 直方图绘制统计各分数段人数，分成4份
girl.describe().round(1)


# In[50]:


plt.hist(girl['女800米跑分数'],bins = 4)  #(0-25 37人；25-50 15人；50-75 157人 75-100 384人)


# In[51]:


#女跳远 进行直方图绘制统计各分数段人数，分成4份
plt.hist(girl['女跳远分数'],bins = 4) #(0-25 19人；25-50 10人；50-75 416人 75-100 148人)


# In[92]:


#使用嵌套饼图对比男女生体重指数进行比例统计，分为正常、低体重、超重、肥胖
#外圈男生 正常：16.5~23.2 低体重：<=16.4 超重：23.3~26.3 肥胖：>=26.4
p1 = pd.cut(boy['BMI'],
            bins = [0,16.5,23.3,26.4,100],
            labels = ['男生低体重','男生正常','男生超重','男生肥胖'])
d1=p1.value_counts()
d1


# In[128]:


plt.rcParams['font.size']=14
plt.rcParams['font.sans-serif'] = 'songti sc' 
plt.figure(figsize=(8,8))
_ = plt.pie(d1,
        autopct='%0.2f%%',
        pctdistance=0.85,
        wedgeprops=dict(linewidth=4,width=0.4,edgecolor='w'),
       labels = d1.index)
_ = plt.pie(data2,
        autopct='%0.2f%%',
        pctdistance=0.7,
        radius=0.6,
        wedgeprops=dict(linewidth=4,width=0.4,edgecolor='w'),
        labels = data2.index)
plt.title('   男女生体重指数统计   ',fontsize = 28,backgroundcolor = '#c5b783',color = 'white' ,pad = 1)


# In[109]:


#内圈女生 正常：16.5~22.7 低体重：<=16.4 超重：22.8~25.2 肥胖：>=25.3
p2 = pd.cut(girl['BMI'],
           bins = [0,16.5,22.8,25.3,40],
           labels = ['女生低体重','女生正常','女生超重','女生肥胖'])
data2 = p2.value_counts()
data2


# In[ ]:




